<?php
/**
* FILE_NAME : second_step.php   FILE_PATH : id5:/id5/web_root/second_step.php
* ….发送手机验证码第二步
*
* @copyright Copyright www.phpunion.com
* @author slash upsetcn@gmail.com
* @package
* @subpackage
* @version Sat Dec 10 21:17:44 CST 2011
*/ 
include_once("ThePage.class.php");
$page = new ThePage();
$temp_id = $page->userRequest->get("temp_id");
if(empty($temp_id))
{
	user_log(0,"-3013","error",$_SERVER['SCRIPT_NAME']);
	$temp = $page->userRequest->user_get_cookie('err_url');
	$err_url = empty($temp) ? "404" :urldecode($temp);
	jumpPage($err_url,'',3);
	exit();
}

$user_mob = isset($_POST['user_mob']) ? trim($_POST['user_mob']) : 0;
//检测手机号
if(!preg_match('/[0-9]{8,20}/',$user_mob))
{
	user_log(0,"-3014","error",$_SERVER['SCRIPT_NAME']);
	goToIndex(-3014);
	exit();
}

$real_name = isset($_POST['real_name']) ? trim($_POST['real_name']) : '';
//真实姓名
if(empty($real_name))
{
	user_log(0,"-3015","error",$_SERVER['SCRIPT_NAME']);
	goToIndex(-3015);
	exit();
}
//临时验证码
$ver_code = isset($_POST['ver_code']) ? trim($_POST['ver_code']) : 0;
if($page->userRequest->get('VCODE') != $ver_code || empty($ver_code))
{
	user_log(0,"-3016","error",$_SERVER['SCRIPT_NAME']);
	goToIndex(-3016);
	exit();
}

//身份证号
$identity_card = isset($_POST['identity_card']) ? trim($_POST['identity_card']) : '';
if(!preg_match('/^[0-9]{15,18}+[x,X]{0,1}$/',$identity_card))
{
	user_log(0,"-3017","error",$_SERVER['SCRIPT_NAME']);
	goToIndex(-3017);
	exit();
}
//追加信息
$user_arr = @unserialize($page->mc->get(SFT.$temp_id));
if(empty($user_arr))
{
	//mc存储失效
	user_log(0,"-3009","error",$_SERVER['SCRIPT_NAME']);
	goToIndex(-3009);
	exit();
}
$user_arr['real_name'] = $real_name;
$user_arr['identity_card'] = $identity_card;
$user_arr['user_mob'] = $user_mob;
$page->mc->set(SFT.$temp_id,serialize($user_arr));

//释放随机码
$page->userRequest->free('VCODE');
//获得下发码
$mob_code = mem_code($user_mob,$resend_time);

//下发验证码
$send_pj = Factory::getItemClass('id5_note');
//
if($send_pj->id5_send($user_arr['icpcode'],$user_mob,$mob_code)){ 
//put_sms($user_mob,$mob_code,$user_arr['icpcode'])){

	//成功结果写入日志文档
	user_log($temp_id,"suc 2","suc",$_SERVER['SCRIPT_NAME']);
	/*$page->smarty->assign('coop_name',get_coop_name($icpcode));
	*/
	//将信息释放给页面
	$page->set_sub_info($user_arr['icpcode']);
	$page->smarty->assign('icpcode',$user_arr['icpcode']);
	$page->smarty->assign('user_mob',$user_mob);
	$page->smarty->display('second_step.tpl');
}else{
	user_log(0,"-3018","error",$_SERVER['SCRIPT_NAME']);
	goToIndex(-3018);
}

exit();

/*

//取得相关信息
$user_arr = unserialize($page->mc->get(SFT.$temp_id));
$user_arr['real_name'] = $real_name;
$user_arr['identity_card'] = $identity_card;
$user_arr['user_mob'] = $user_mob;
$page->mc->set(SFT.$temp_id,serialize($user_arr));
$icpcode = $user_arr['icpcode'];
$v_code = $page->userRequest->get('VCODE');
if($v_code!=$ver_code){
	alertMsg('-3002');
	exit;
}
if(empty($temp_id) || empty($user_mob) || empty($real_name) || empty($identity_card) || empty($icpcode)){
	alertMsg('-3001');
	exit;
}

//注销验证码
//$page->userRequest->free('VCODE');
//生成手机验证码
echo $mob_code = mem_code($user_mob);
if(put_sms($user_mob,$mob_code,11111111)){
	$page->smarty->assign('coop_name',get_coop_name($icpcode));
	$page->smarty->assign('user_mob',$user_mob);
	$page->smarty->assign('icpcode',$icpcode);
	$page->smarty->display('second_step.tpl');
}else{
	alertMsg('-3003');
}
*/
